<template>
  <div class="card-wk">
    <ul v-if="dataList.length > 0">
      <li v-for="(item, i) in dataList" :key="i">
        <div class="card-list-top">
          <img :src="item.companyLogo || require('@/assets/images/import/jrcp01.png')" alt="">
          <div class="card-list-description">
            <h4>{{ item.productName }}</h4>
            <p :title="item.version">{{ item.version }}</p>
          </div>
        </div>
        <div class="card-list-btn">
          <el-button size="mini" type="text" @click="handleUpdate(item, i)">编辑 </el-button>
          <el-button size="mini" type="text" @click="handleDelete(item, i)">删除 </el-button>
        </div>
      </li>
      <span />
      <span />
      <span />
    </ul>
    <div v-else class="empty">暂无数据</div>
  </div>
</template>

<script>
export default {
  name: 'StyleType',
  props: {
    dataList: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      loading: false
    }
  },
  methods: {
    handleUpdate(obj, i) {
      this.$emit('handleUpdate', { object: obj, index: i })
    },
    handleDelete(obj, i) {
      this.$emit('handleDelete', { object: obj, index: i })
    }
  }
}
</script>

<style scoped lang="scss">
.empty {
  text-align: center;
  padding: 5% 0;
  color: #909399;
}
h4,
p {
  margin: 0;
  font-size: 14px;
}

@mixin hk-flex {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}

// 列表类型
.card-wk {
  ul {
    @include hk-flex;
    padding: 0 !important;
    li {
      border-radius: 4px;
      border: 1px solid rgba(0, 0, 0, 0.15);
      width: calc(20% - 20px);
      min-width: 210px;
      list-style: none;
      margin: 10px 0;
      padding: 0 !important;
      display:flex;
      flex-direction: column;
      &:nth-of-type(1),
      &:nth-of-type(2),
      &:nth-of-type(3),
      &:nth-of-type(4),
      &:nth-of-type(5) {
        margin-top: 0 !important;
      }
      .card-list-top {
        flex:1;
        @include hk-flex;
        padding: 20px 10px;
        align-items: center;
        flex-wrap: nowrap;
        img {
          width: 60px;
          height: 60px;
        }
        .card-list-description {
          width:calc(100% - 60px);
          margin-left: 10px;
          flex: 1;
          line-height: 30px;
          h4{
            word-break: break-all;
          }
          p {
            color: rgba(0, 0, 0, 0.45);
            display: block;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
          }
        }
      }

      .card-list-btn {
        display: flex;
        border-top: 1px solid rgba(0, 0, 0, 0.15);
        button {
          flex: 1;
          width: 50%;
          display: inline-block;
          height: 40px;
          color: rgba(0, 0, 0, 0.45);
          &:nth-of-type(1) {
            border-right: 1px solid rgba(0, 0, 0, 0.08);
          }
          &:hover {
            color: #4b6eef;
          }
        }
      }
    }
    > span {
      width: calc(20% - 20px);
    }
  }
}
</style>
